Skip to content

[cross_file] Clarify MIME type docs#11727

Open
mackings wants to merge 3 commits into
flutter:mainfrom
mackings:docs-cross-file-mimetype
Open

[cross_file] Clarify MIME type docs#11727
mackings wants to merge 3 commits into
flutter:mainfrom
mackings:docs-cross-file-mimetype

Conversation

@mackings
Copy link
Copy Markdown

@mackings mackings commented May 18, 2026

Clarifies the cross_file documentation for XFile.mimeType.

This PR documents that mimeType is not inferred from the file path or file contents. It is only available when provided while creating the XFile, or when available from the platform-backed file.

Fixes flutter/flutter#93379

Test exemption: This is a documentation-only change that clarifies existing API behavior, so no new tests were added.

Validation run:

  • dart analyze
  • dart test
  • dart test test/readme_excerpts_test.dart

Pre-Review Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools.
  • I read the [Tree Hygiene] page, which explains my responsibilities.
  • I read and followed the [relevant style guides] and ran [the auto-formatter].
  • I signed the [CLA].
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I [linked to at least one issue that this PR fixes] in the description above.
  • I added new tests to check the change I am making, or I have commented below to indicate which [test exemption] this PR falls under[^1].
  • I [linked to at least one issue that this PR fixes] in the description above.
  • I followed [the version and CHANGELOG instructions], using [semantic versioning] and the [repository CHANGELOG style], or I have commented below to indicate which documented exception this PR falls under[^1].
  • I updated/added any relevant documentation (doc comments with ///).
  • Added packages/cross_file/pubspec.yaml version bump: 0.3.5+2 -> 0.3.5+3
  • Changed CHANGELOG.md from ## NEXT to ## 0.3.5+3
  • All existing and new tests are passing.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the documentation for XFile to clarify that the mimeType property is not automatically inferred from file paths or contents. These updates are reflected in the CHANGELOG.md, README.md, and the base and IO implementations of XFile. Feedback was provided to improve the clarity of the documentation in the XFile constructors by explicitly stating that the mimeType is only available if passed to the constructor, and to ensure consistency by applying similar updates to the HTML implementation.

Comment on lines +27 to +28
/// [mimeType] is not inferred from [path] and is returned from [mimeType]
/// only if explicitly passed.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The phrasing "returned from [mimeType]" is confusing because [mimeType] is used for both the parameter and the property in this context. It would be clearer to state that the property is only available if the parameter is provided. Additionally, for consistency, please consider applying similar documentation updates to the XFile constructors in lib/src/types/html.dart.

Suggested change
/// [mimeType] is not inferred from [path] and is returned from [mimeType]
/// only if explicitly passed.
/// [mimeType] is not inferred from [path] and is only available if explicitly
/// passed to the constructor.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the wording in io.dart and added matching constructor documentation in html.dart. Tests still pass.

@@ -40,6 +43,8 @@ class XFile extends XFileBase {

/// Construct an CrossFile from its data
///
/// [mimeType] is returned from [mimeType] only if explicitly passed.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The phrasing "returned from [mimeType]" is redundant. It's clearer to specify that the value is only available if provided during construction.

Suggested change
/// [mimeType] is returned from [mimeType] only if explicitly passed.
/// [mimeType] is only available if explicitly passed to the constructor.

@mackings mackings force-pushed the docs-cross-file-mimetype branch from ddb605b to 1a79271 Compare May 18, 2026 09:37
@stuartmorgan-g
Copy link
Copy Markdown
Collaborator

Thanks for the contribution! You’ve checked boxes in the PR checklist above that are not reflected in this PR, so I’m assuming this is a work in progress and am marking it as a Draft. Please review the checklist, updating the PR as appropriate, and when the state of the PR as posted reflects the checklist please feel free to mark it as ready for review.

@stuartmorgan-g stuartmorgan-g marked this pull request as draft May 18, 2026 14:40
@mackings mackings marked this pull request as ready for review May 19, 2026 12:41
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the documentation for XFile to specify that mimeType is not inferred from file paths or contents. The review feedback suggests refining the language for clarity and consistency across platforms, specifically by removing references to platform-backed files and explicitly stating the lack of inference in all relevant constructors.

Comment on lines +50 to +52
/// The value is not inferred from the file contents or path. It is only
/// available if provided when the [XFile] was created, or if available from
/// the platform-backed file.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The phrase "or if available from the platform-backed file" is potentially confusing. Since mimeType is a synchronous getter and the implementations in this package only return the value provided during construction, this phrase might lead users to expect some form of automatic detection for certain files. It's clearer to state that it must be provided at creation, which covers both manual instantiation and cases where a platform plugin provides the value.

Suggested change
/// The value is not inferred from the file contents or path. It is only
/// available if provided when the [XFile] was created, or if available from
/// the platform-backed file.
/// The value is not inferred from the file contents or path. It is only
/// available if provided when the [XFile] was created.

Comment thread packages/cross_file/README.md Outdated
Comment on lines +26 to +28
The `mimeType` property is not inferred from the file path or contents. It is
only available if provided when the `XFile` was created, or if available from the
platform-backed file.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Similar to the base class documentation, the mention of "platform-backed file" here is redundant and may cause confusion regarding whether the MIME type is automatically detected in some scenarios. Simplifying this to focus on the requirement of providing it at creation improves clarity.

Suggested change
The `mimeType` property is not inferred from the file path or contents. It is
only available if provided when the `XFile` was created, or if available from the
platform-backed file.
The `mimeType` property is not inferred from the file path or contents. It is
only available if provided when the `XFile` was created.

/// `name` needs to be passed from the outside, since it's only available
/// while handling [html.File]s (when the ObjectUrl is created).
///
/// [mimeType] is only available if explicitly passed to the constructor.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with the io implementation and to be explicitly clear, it's helpful to mention that the MIME type is not inferred from the path (which is a Blob URL on web).

Suggested change
/// [mimeType] is only available if explicitly passed to the constructor.
/// [mimeType] is not inferred from [path] and is only available if explicitly
/// passed to the constructor.


/// Construct an CrossFile from its data
///
/// [mimeType] is only available if explicitly passed to the constructor.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This constructor also accepts an optional path. For consistency with the main XFile constructor in this file, it should explicitly state that the MIME type is not inferred from that path.

Suggested change
/// [mimeType] is only available if explicitly passed to the constructor.
/// [mimeType] is not inferred from [path] and is only available if explicitly
/// passed to the constructor.

@stuartmorgan-g
Copy link
Copy Markdown
Collaborator

  • I followed [the version and CHANGELOG instructions], using [semantic versioning] and the [repository CHANGELOG style], or I have commented below to indicate which documented exception this PR falls under[^1].

I don't see any changes addressing this item.

@stuartmorgan-g stuartmorgan-g marked this pull request as draft May 19, 2026 15:28
@stuartmorgan-g stuartmorgan-g changed the title Clarify cross_file MIME type docs [cross_file] Clarify MIME type docs May 19, 2026
@mackings
Copy link
Copy Markdown
Author

mackings commented May 19, 2026 via email

@mackings mackings marked this pull request as ready for review May 19, 2026 16:03
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request clarifies that the mimeType property in the cross_file package is not inferred from the file path or contents. Documentation updates reflecting this behavior were made in the CHANGELOG.md, README.md, and the XFile class across its base, HTML, and IO implementations. I have no feedback to provide.

@stuartmorgan-g
Copy link
Copy Markdown
Collaborator

I will update the PR checks.

It appears that your change was to delete the checklist item. Could you explain why you believe that our required contribution steps do not apply to this PR?

@mackings mackings force-pushed the docs-cross-file-mimetype branch from ea8232e to df9109d Compare May 19, 2026 19:47
@mackings
Copy link
Copy Markdown
Author

mackings commented May 19, 2026 via email

@stuartmorgan-g stuartmorgan-g self-requested a review May 20, 2026 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[cross_file] Document that mimeType is not expected to be set for io implementation

2 participants